var e, t = require("../../../../store/index"), a = ((e = t) && e.__esModule, require("../../../../api/log"));

Component({
    externalClasses: [ "x-class" ],
    properties: {
        show: {
            type: Boolean,
            value: !1
        },
        detail: {
            type: Object,
            value: function() {}
        },
        prole: {
            type: String,
            value: ""
        }
    },
    data: {
        popupShow: !1,
        memberInfo: {},
        list: [],
        page: 1,
        finished: !1,
        loading: !1
    },
    observers: {
        "show, detail": function() {
            var e = 0 < arguments.length && void 0 !== arguments[0] && arguments[0], t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {};
            this.setData({
                popupShow: e,
                page: 1,
                list: [],
                finished: !1,
                memberInfo: t
            }), e && this._fetch();
        }
    },
    methods: {
        onPopupClose: function() {
            this.triggerEvent("close");
        },
        onScrollBottom: function() {
            this._fetch();
        },
        _fetch: function() {
            var e = this;
            return new Promise(function(t, i) {
                if (e.data.loading || e.data.finished) return t([]);
                var o = (n = e.data.memberInfo).openid, n = n.role, s = e.data.page;
                e.setData({
                    loading: !0
                }), (0, a.getTodayLink)({
                    openid: o,
                    role: n,
                    page: s
                }).then(function(a) {
                    var i;
                    a && a.length ? (i = e.data.list, e.setData({
                        list: i.concat(a),
                        page: s + 1,
                        loading: !1,
                        finished: !1
                    })) : 1 == +s ? e.setData({
                        list: [],
                        finished: !0,
                        loading: !1,
                        page: s + 1
                    }) : e.setData({
                        finished: !0,
                        loading: !1,
                        page: s + 1
                    }), t(a);
                }).catch(function() {
                    e.setData({
                        loading: !1
                    }), app.utils.toastText("数据加载失败");
                });
            });
        }
    }
});